﻿<navigation:Page
  x:Class="demo.Home" 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
  mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"  
  Style="{StaticResource PageStyle}" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

  <Grid x:Name="LayoutRoot">
    <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">

      <StackPanel x:Name="ContentStackPanel" Style="{StaticResource ContentStackPanelStyle}">

        <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" 
                           Text="{Binding Path=Strings.HomePageTitle, Source={StaticResource ApplicationResources}}"/>
                
          

           
                <StackPanel Orientation="Horizontal">
                    <sdk:DataGrid AutoGenerateColumns="false" Height="250" HorizontalAlignment="Left" Margin="20" Name="dgDepts" VerticalAlignment="Top" Width="500" 
                          ItemsSource="{Binding Departments, Mode=TwoWay}"
                          SelectionMode="Single"
                          SelectedItem="{Binding Path=SelectedDepartment, Mode=TwoWay}"
                          SelectionChanged="dgDepts_SelectionChanged"
                          >

                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn Binding="{Binding Path=ID}" Header="ID" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="300" />
                            <sdk:DataGridTextColumn Binding="{Binding Path=Name}" Header="Department Name" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="150" />
                        </sdk:DataGrid.Columns>

                    </sdk:DataGrid>


                    <sdk:DataGrid AutoGenerateColumns="False" Height="250" HorizontalAlignment="Left" Margin="0,20,0,0" Name="dgEmps" VerticalAlignment="Top" 
                          ItemsSource="{Binding Path=SelectedDepartment.EmployeesByName, Mode=TwoWay}"
                          >

                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn Binding="{Binding Path=Name}" Header="Employee" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="80" />
                            <sdk:DataGridTextColumn Binding="{Binding Path=Addr}" Header="Address" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="80" />
                            <sdk:DataGridTextColumn Binding="{Binding Path=Ext}" Header="Ext" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="50" />
                        </sdk:DataGrid.Columns>


                    </sdk:DataGrid>
                </StackPanel>
                <CheckBox Content="Eager Load" Height="16" Name="cbLazyLoad" Click="cbLazyLoad_Click" IsChecked="{Binding EagerLoad, Mode=TwoWay}" Margin="20,0,0,0" />
                <StackPanel Orientation="Horizontal" Margin="20">

                    <Button Content="Save Changes" Height="23"  Name="btnSaveChanges" VerticalAlignment="Top" Click="btnSaveChanges_Click" Margin="10" />
                    <Button Content="New Dept" Height="23" Name="btnNewDept" VerticalAlignment="Top" Click="btnNewDept_Click" Margin="10" />
                    <Button Content="New Employee" Height="23" Name="btnNewEmp" VerticalAlignment="Top" Click="btnNewEmp_Click" IsEnabled="{Binding ElementName=dgDepts, Path=SelectedIndex, Converter={StaticResource SelectedEnabledConverter}}" Margin="10" />
                </StackPanel>
  
          
          
          
            </StackPanel>

    </ScrollViewer>
  </Grid>

</navigation:Page>